package special_tree;

import code.CodeList;
import code.Opcode;

import compiler.CompilerException;

import lexer.Token;
import tree.DataType;
import tree.MyTree;
import tree.Type;
import tree.TypingException;

public class InputTree extends MyTree {

	@Deprecated
	private Type typ;
	
	public InputTree(Token t, Type typ) {
		super(t);
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#computeType()
	 */
	@Override
	@Deprecated
	public Type computeType() throws TypingException {
		return this.typ;
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#generateCode(code.CodeList)
	 */
	@Override
	@Deprecated
	public void generateCode(CodeList code) throws CompilerException {
		if (this.typ.equals(new Type(DataType.CHAR,""))) {
			code.generateCode(Opcode.READCHAR);
		}
		else if (this.typ.equals(new Type(DataType.DOUBLE, ""))) {
			code.generateCode(Opcode.READDOUBLE);
		}
		else if (this.typ.equals(new Type(DataType.INT, ""))) {
			code.generateCode(Opcode.READINT);
		}
		else {
			throw new CompilerException("InputType not available");
		}
	}
	
}
